package cn.iocoder.yudao.module.nmkj.controller.app.teamintroduce;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.nmkj.controller.admin.teamintroduce.vo.TeamIntroducePageReqVO;
import cn.iocoder.yudao.module.nmkj.controller.admin.teamintroduce.vo.TeamIntroduceRespVO;
import cn.iocoder.yudao.module.nmkj.dal.dataobject.teamintroduce.TeamIntroduceDO;
import cn.iocoder.yudao.module.nmkj.service.teamintroduce.TeamIntroduceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户APP - 团队介绍")
@RestController
@RequestMapping("/nmkj/team-introduce")
@Validated
public class AppTeamIntroduceController {

    @Resource
    private TeamIntroduceService teamIntroduceService;

    @GetMapping("/page")
    @Operation(summary = "获得团队介绍分页")
    public CommonResult<PageResult<TeamIntroduceRespVO>> getTeamIntroducePage(@Valid TeamIntroducePageReqVO pageReqVO) {
        pageReqVO.setStatus(1); //用户端只允许查询启用状态
        PageResult<TeamIntroduceDO> pageResult = teamIntroduceService.getTeamIntroducePage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, TeamIntroduceRespVO.class));
    }

    @GetMapping("/list")
    @Operation(summary = "获得团队介绍列表")
    public CommonResult<List<TeamIntroduceRespVO>> getTeamIntroduceList(@Valid TeamIntroducePageReqVO reqVO) {
        List<TeamIntroduceDO> listResult = teamIntroduceService.getTeamIntroduceList(reqVO);
        return success(BeanUtils.toBean(listResult, TeamIntroduceRespVO.class));
    }

}
